crc
Rust implementation of CRC(16, 32, 64) with support of various standards
Usage
Add crc
to Cargo.toml
[]
= "^1.0.0"
or
[]
= "https://github.com/mrhooray/crc-rs"
Add this to crate root
extern crate crc;
Compute CRC16
use ;
assert_eq!;
assert_eq!;
// use provided or custom polynomial
let mut digest = new;
digest.write;
assert_eq!;
// with initial
let mut digest = new_with_initial;
digest.write;
assert_eq!;
Compute CRC32
use ;
// CRC-32-IEEE being the most commonly used one
assert_eq!;
assert_eq!;
assert_eq!;
// use provided or custom polynomial
let mut digest = new;
digest.write;
assert_eq!;
// with initial
let mut digest = new_with_initial;
digest.write;
assert_eq!;
Compute CRC64
use ;
assert_eq!;
assert_eq!;
// use provided or custom polynomial
let mut digest = new;
digest.write;
assert_eq!;
// with initial
let mut digest = new_with_initial;
digest.write;
assert_eq!;
Benchmark
Bencher is currently not available in Rust stable releases.
cargo bench
with 2.3 GHz Intel Core i7 results ~430MB/s throughput. Comparison
cargo bench
Running target/release/bench-5c82e94dab3e9c79
running 4 tests
test bench_crc32_make_table ... bench: 439 ns/iter (+/- 82)
test bench_crc32_update_megabytes ... bench: 2327803 ns/iter (+/- 138845)
test bench_crc64_make_table ... bench: 1200 ns/iter (+/- 223)
test bench_crc64_update_megabytes ... bench: 2322472 ns/iter (+/- 92870)
test result: ok. 0 passed; 0 failed; 0 ignored; 4 measured
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.